﻿using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

namespace Studio
{
	// Token: 0x02000503 RID: 1283
	public class SortCanvas : Singleton<SortCanvas>
	{
		// Token: 0x170003CD RID: 973
		// (set) Token: 0x06002086 RID: 8326 RVA: 0x000C92B8 File Offset: 0x000C74B8
		public static Canvas select
		{
			set
			{
				if (Singleton<SortCanvas>.IsInstance())
				{
					Singleton<SortCanvas>.Instance.OnSelect(value);
				}
			}
		}

		// Token: 0x06002087 RID: 8327 RVA: 0x000C92D0 File Offset: 0x000C74D0
		public void OnSelect(Canvas _canvas)
		{
			if (_canvas == null)
			{
				return;
			}
			SortedList<int, Canvas> sortedList = new SortedList<int, Canvas>();
			_canvas.sortingOrder = 10;
			for (int j = 0; j < this.canvas.Length; j++)
			{
				sortedList.Add(this.canvas[j].sortingOrder, this.canvas[j]);
			}
			foreach (var callback in sortedList.Select((KeyValuePair<int, Canvas> l, int i) => new
			{
				l.Value,
				i
			}))
			{
				callback.Value.sortingOrder = callback.i;
			}
		}

		// Token: 0x06002088 RID: 8328 RVA: 0x000C93A0 File Offset: 0x000C75A0
		protected override void Awake()
		{
			if (!base.CheckInstance())
			{
				return;
			}
			UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
		}

		// Token: 0x0400223E RID: 8766
		[SerializeField]
		private Canvas[] canvas;
	}
}
